home *** CD-ROM | disk | FTP | other *** search
- /* Assemble the source in the current window of CygnusEd using BAsm.
- **
- ** This ARexx script assembles the source found in the currently
- ** active window of CygnusEd (which activates this script).
- **
- ** Written and copyright 1995-1996 by Ulrich Flegel.
- ** All rights are reserved to the author Ulrich Flegel.
- **
- ** Publication and distribution only allowed by explicitly written permission from the author.
- ** This software may be distribute on the Aminet CD-ROMs.
- **
- ** system requirements:
- ** NextError.ced (V1.1 or higher)
- ** CygnusEd (V3.5 or higher)
- ** BAsm (V1.123 or higher)
- ** Run (AmigaOS release)
- ** WaitForPort (ARexx release)
- ** rx (ARexx release)
- **
- ** current version of this script:
- **
- ** $VER: Assemble.ced V1.1 (06-Jan-95)
- **
- ** usage:
- ** call as ARexx Macro from CygnusEd as: "Assemble.ced [LOCALE «Language»] [OPT «BAsmOptions»]"
- ** Example «Language»: deutsch
- ** Example «BAsmOptions»: -O+ -OW+
- */
-
- /*============================================================================*/
-
- OPTIONS RESULTS /* enable return codes */
-
- /*============================================================================*/
-
- /* parameters used to control this program */
-
- /* Assemble.ced [PORT «Port_CygnusEd»] [LOCALE «Language»] [OPT «BAsmOptions»] */
-
- PARSE ARG CommandLine
-
- /*============================================================================*/
-
- /* adapt the following variables to your system environment: */
-
- NextError = 'BAsmify:NextError.ced' /* here substitute the complete path/name of the NextError.ced script */
- LaunchCmd = 'C:Run >NIL:' /* here substitute the command line how to launch BAsm in background */
- BAsmPath = 'Work:Programming/Assembler/Barfly/' /* here substitute the path where to find BAsm (don't forget the trailing "/") */
- BAsmName = 'BAsm' /* here substitute the name you gave BAsm */
- BAsmStartup = '-A' /* here substitute the startup option needed to make BAsm listen to it's port */
- TempPath = 'T:' /* here substitute the path where temporary data is to store */
-
- /*============================================================================*/
-
- BAsmError_Max = 200
- BAsmError_OK = 0
- BAsmError_False = 20
- BAsmError_OpenError = 1
- BAsmError_SourceError = 2
- BAsmError_ReadError = 3
- BAsmError_UnknownOption = 4
- BAsmError_MemoryError = 5
- BAsmError_NoSourceFile = 6
- BAsmError_NoNextError = 7
- BAsmError_NoErrorList = 8
- BAsmError_NoNextWarning = 9
- BAsmError_NoWarningList = 10
-
- /*============================================================================*/
-
- /*
- ** Intialize parameter variables and parse commandline
- */
-
- Port_CygnusEd=''
- Language=''
- BAsmOptions=''
-
- DO FOREVER
- PARSE VAR CommandLine Parameter CommandLine
- IF Parameter = '' THEN LEAVE
- PARSE VAR CommandLine Argument CommandLine
- IF Argument = '' THEN LEAVE
-
- SELECT
- WHEN Parameter = 'PORT' THEN Port_CygnusEd=Argument
- WHEN Parameter = 'LOCALE' THEN Language=Argument
- WHEN Parameter = 'OPT' THEN BAsmOptions=Argument||CommandLine
- END
- END
-
- /*============================================================================*/
-
- /* ARexx ports used */
-
- Port_BAsm='rexx_BASM'
-
- IF (Port_CygnusEd='') THEN Port_CygnusEd=ADDRESS()
- IF (LEFT(Port_CygnusEd, 8) ~= 'rexx_ced') THEN Port_CygnusEd='rexx_ced'
-
- /*============================================================================*/
-
- ScriptErrorLevel = 6
-
- SIGNAL ON SYNTAX /* ensure clean exit */
-
- IF ~ SHOW('P', Port_CygnusEd) THEN /* is CygnusEd AREXX port available ? */
- DO
- Say 'This script may only called by CygnusEd!'
- END
- ELSE
- DO
-
- OPTIONS FAILAT ScriptErrorLevel /* ignore warnings */
-
- /*============================================================================*/
-
- /*
- ** Non localized strings used
- */
-
- STRING_ThisScript='Assemble.ced'
-
- /*
- ** Localization of strings used
- */
-
- IF ( Language = '' ) THEN /* ask CED for current language if none submitted */
- DO
- ADDRESS VALUE Port_CygnusEd
- /*'QUERY CAT'*/ /* !!! here find out which language CED uses currently */
- /*Language=RESULT*/
- END
-
- SELECT
- WHEN Language='deutsch' THEN
- DO
- STRING_Positive='OK'
- STRING_Negative='Abbrechen'
- STRING_Dismiss='Aufgeben'
- STRING_BAsmFailure_Title='BAsm Fehler-Report'
- ERROR_NoSource='Kein Source vorhanden!'
- ERROR_NoBAsm="'"||BAsmPath||BAsmName||"' konnte nicht gefunden werden!"
- ERROR_BAsmWarnings='Assemblierung mit Warnungen abgeschlossen.'
- ERROR_BASM_UnknownErrorCode='Ein unbekannter Fehler ist aufgetreten!'
- ERROR_BASM_OK='Assemblierung erfolgreich abgeschlossen.'
- ERROR_BASM_False='Assemblierung aufgrund von Fehlern abgebrochen!'
- ERROR_BASM_OpenError='Datei konnte nicht gefunden werden!'
- ERROR_BASM_SourceError='Source Datei ist KEIN ASCII!'
- ERROR_BASM_ReadError='Datei Lesefehler!'
- ERROR_BASM_UnknownOption='Unbekannte BAsm Option(en) angegeben: '||BAsmOptions||'!'
- ERROR_BASM_MemoryError='Nicht genug Speicher!'
- ERROR_BASM_NoSourceFile='Keine Source Datei angegeben!'
- END
- /*
- WHEN Language='XXX' THEN
- DO
- STRING_Positive='XXX'
- STRING_Negative='XXX'
- STRING_Dismiss='XXX'
- STRING_BAsmFailure_Title='XXX'
- ERROR_NoSource='XXX!'
- ERROR_NoBAsm="'"||BAsmPath||BAsmName||"'XXX!"
- ERROR_BAsmWarnings='XXX.'
- ERROR_BASM_UnknownErrorCode='XXX!'
- ERROR_BASM_OK='XXX!'
- ERROR_BASM_False='XXX!'
- ERROR_BASM_OpenError='XXX!'
- ERROR_BASM_SourceError='XXX!'
- ERROR_BASM_ReadError='XXX!'
- ERROR_BASM_UnknownOption='XXX: '||BAsmOptions||'!'
- ERROR_BASM_MemoryError='XXX!'
- ERROR_BASM_NoSourceFile='XXX!'
- END
- */
- OTHERWISE
- DO
- STRING_Positive='OK'
- STRING_Negative='Cancel'
- STRING_Dismiss='Dismiss'
- STRING_BAsmFailure_Title='BAsm error report'
- ERROR_NoSource='No source available!'
- ERROR_NoBAsm="'"||BAsmPath||BAsmName||"' couldn't be found!"
- ERROR_BAsmWarnings='Assembly finished with warnings.'
- ERROR_BASM_UnknownErrorCode='An unknown error occurred!'
- ERROR_BASM_OK='Assembly successfully finished.'
- ERROR_BASM_False='Assembly stopped due to errors!'
- ERROR_BASM_OpenError='Open file error during assembly'
- ERROR_BASM_SourceError='A source file is NOT ASCII!'
- ERROR_BASM_ReadError='Read file error during assembly!'
- ERROR_BASM_UnknownOption='Unknown BAsm option(s) supplied: '||BAsmOptions||'!'
- ERROR_BASM_MemoryError='Not enough memory to finish assembly!'
- ERROR_BASM_NoSourceFile='No source file specified!'
- END
- END
-
- /*============================================================================*/
-
- /*
- ** Prepare arguments for invocation of NextError.ced
- */
-
- IF ( Port_CygnusEd = '' ) THEN
- Cmd_PORT=''
- ELSE
- Cmd_PORT='PORT '||Port_CygnusEd
-
- IF ( Language = '' ) THEN
- Cmd_LOCALE=''
- ELSE
- Cmd_LOCALE='LOCALE '||Language
-
- IF ( BAsmOptions = '' ) THEN
- Cmd_OPT=''
- ELSE
- Cmd_OPT='OPT '||BAsmOptions
-
- /*============================================================================*/
-
- /*
- ** Finally do something
- */
-
- ADDRESS VALUE Port_CygnusEd
- 'STATUS 16'
- IF (RESULT=0) THEN
- /*
- ** PATH: No source available
- */
- DO
- 'OKAY1 '||ERROR_NoSource
- END
- ELSE
- /*
- ** PATH: Assemble source
- */
- DO
- /*==== Save if file source modified ====*/
-
- ADDRESS VALUE Port_CygnusEd
- 'STATUS 18'
- IF ~(RESULT=0) THEN 'SAVE'
-
- 'STATUS 21'
- Filename_Source=RESULT
-
- 'STATUS 19'
- Pathname_Source=RESULT
-
- /*==== checking presence of BAsm ====*/
-
- RemoveBAsmAfterProcessing = FALSE /* indicates wether BAsm is to remove after processing (e.g. because it was not existent before) */
-
- IF Filename_Source = '' THEN
- DO
- 'OKAY1 '||ERROR_NoSource
- END
- ELSE
- DO
- IF ~ SHOW('P', Port_BAsm) THEN /* is BAsm AREXX port available ? */
- DO
- ADDRESS COMMAND LaunchCmd||' '||BAsmPath||BAsmName||' '||BAsmStartup /* no, launch BAsm */
-
- IF RC = 0 THEN
- DO /* no error occured ? */
- RemoveBAsmAfterProcessing = TRUE /* BAsm had to be loaded, so it must be removed after processing */
- ADDRESS COMMAND WaitForPort Port_BAsm
- END
- ELSE
- DO
- ADDRESS VALUE Port_CygnusEd
- 'OKAY1 '||ERROR_NoBAsm
- EXIT 0
- END
- END
-
- IF ~ SHOW('P', Port_BAsm) THEN /* is BAsm running ? */
- DO
- ADDRESS VALUE Port_CygnusEd
- 'OKAY1 '||ERROR_NoBAsm
- END
- ELSE
- DO
- ADDRESS VALUE Port_BAsm /* Hey, BAsm, listen to your master */
-
- /*==== remote control BAsm now ====*/
-
- OPTIONS FAILAT BAsmError_Max
- 'BASM -e+ -es- '||BAsmOptions||' '||PathName_Source
-
- ADDRESS VALUE Port_CygnusEd
-
- SELECT
- WHEN RC = BAsmError_OpenError THEN
- 'OKAY1 '||ERROR_BASM_OpenError
- WHEN RC = BAsmError_SourceError THEN
- 'OKAY1 '||ERROR_BASM_SourceError
- WHEN RC = BAsmError_ReadError THEN
- 'OKAY1 '||ERROR_BASM_ReadError
- WHEN RC = BAsmError_UnknownOption THEN
- 'OKAY1 '||ERROR_BASM_UnknownOption
- WHEN RC = BAsmError_MemoryError THEN
- 'OKAY1 '||ERROR_BASM_MemoryError
- WHEN RC = BAsmError_NoSourceFile THEN
- 'OKAY1 '||ERROR_BASM_NoSourceFile
- WHEN RC = BAsmError_False THEN
- DO
- 'OKAY1 '||ERROR_BASM_False
- /*---- call Error display routine ----*/
- ADDRESS COMMAND 'SYS:RexxC/rx '||NextError||' '||Cmd_PORT||' '||Cmd_LOCALE||' '||Cmd_OPT||' '
- END
- WHEN RC = BAsmError_OK THEN
- DO
- ADDRESS VALUE Port_BAsm
- 'BINITWARNING'
- IF (RC = BAsmError_NoWarningList) THEN
- DO
- ADDRESS VALUE Port_CygnusEd
- 'OKAY1 '||ERROR_BASM_OK
- END
- ELSE
- DO
- ADDRESS VALUE Port_CygnusEd
- 'OKAY1 '||ERROR_BAsmWarnings
- /*---- call Error display routine ----*/
- ADDRESS COMMAND 'SYS:RexxC/rx '||NextError||' '||Cmd_PORT||' '||Cmd_LOCALE||' '||Cmd_OPT||' '
- END
- END
- OTHERWISE
- 'OKAY1 '||ERROR_BASM_UnknownErrorCode
-
- OPTIONS FAILAT ScriptErrorLevel
- END
-
- /*
- IF (RemoveBAsmAfterProcessing = TRUE) THEN
- DO
- ADDRESS VALUE Port_BAsm
- 'BEND'
- END
- */
- END
- END
- END
-
- /*=============================================================================*/
-
- END /* IF ~ SHOW('P', Port_CygnusEd) */
-
- EXIT
-
- SYNTAX:
-
- SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
- ADDRESS VALUE Port_CygnusEd
- 'OKAY1 Script error!'
- EXIT
-
- /*=============================================================================*/
-
-
- /*
- ** version history:
- ** ---------------
- **
- ** V1.0 : -first public version
- **
- ** V1.1 : -second public version
- **
- ** -enhanced locale handling
- ** -fixed port handling
- ** -fixed options handling
- **
- ** known bugs in the latest version/revision:
- ** -----------------------------------------
- ** - No smart localization supported. I don't know the ARexx CygnusEd command to find out the currect used language.
- **
- */
-
-